<template name="ProfilePanel">
  <div class="user-panel">
    <div class="pull-left image">
      {{> avatar user=currentUser shape="circle" class="img-circle align-center" size="mlarge"}}
      {{> avatar user=currentUser shape="circle" class="img-circle align-center" size="tiny"}}
    </div>
    <div class="pull-left info">
      <p>
        <span class="name">{{currentUser.name}}</span>
        <i class="fa fa-circle text-success pull-right"></i>
      </p>
      <div class="text-muted">
        {{currentUser.title}}
      </div>
    </div>
  </div>
</template>

<template name="ProfileModal">
  <div class="modal fade full-screen">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">&times;</button>
          <h4 class="modal-title">{{_ "app_profile"}}</h4>
        </div>
        {{#autoForm collection=formCollection schema=formSchema id="profile-form" doc=currentUser.profile type="normal"}}
          <div class="modal-body scroll-box">
            <div class="form-group">
              {{> avatar user=currentUser shape="circle" class="img-circle form-group" size="profile"}}
              <input type="file" style="display:none;" id="avatar-file" accept="image/*"/>
              <button class="btn btn-default" style="width:180px;" id="btn-upload-avatar">{{_ 'profile_upload_new_picture'}}</button>
            </div>
            <div class="form-group">
              <button class="btn btn-default" style="width:180px;" id="btn-change-password">{{_ 'profile_change_password'}}</button>
            </div>
            {{> afQuickField name="language" defaultValue=currentUser.language firstOption=false}}
            {{> afQuickField name="skin" defaultValue="blue" firstOption=false}}
            {{> afQuickField name="message"}}
            {{> afQuickField name="signature" defaultValue=currentUser.signature}}

            {{#markdown}}> {{{signature}}}{{/markdown}}
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-danger pull-left" id="btn-sign-out">{{_ 'app_sign_out'}}</button>
            <button type="button" class="btn btn-default" data-dismiss="modal" aria-label="Close">{{_ 'app_action_discard'}}</button>
            <button type="submit" class="btn btn-primary">{{_ "app_action_confirm"}}</button>
          </div>
        {{/autoForm}}
      </div>
    </div>
  </div>
</template>

<template name="ChangePasswordModal">
  <div class="modal fade modal-rounded">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">&times;</button>
          <h4 class="modal-title">{{_ "profile_change_password"}}</h4>
        </div>
        {{#autoForm collection=formCollection schema=formSchema id="change-password-form" type="normal"}}
          <div class="modal-body">
            {{> afQuickField name="passwordCurrent"}}
            {{> afQuickField name="password"}}
            {{> afQuickField name="passwordConfirm"}}
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal" aria-label="Close">{{_ 'app_action_discard'}}</button>
            <button type="submit" class="btn btn-primary">{{_ "app_action_confirm"}}</button>
          </div>
        {{/autoForm}}
      </div>
    </div>
  </div>
</template>

<template name="AvatarUploadModal">
  <div class="modal fade modal-rounded">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">&times;</button>
          <h4 class="modal-title">{{_ "profile_upload_new_picture"}}</h4>
        </div>
        <div class="modal-body">
          {{#with currentUpload}}{{> spinner}}{{/with}}
          <div id="image-preview" style="width:100%;height:100%;" class="center-block">{{> spinner}}</div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal" aria-label="Close">{{_ 'app_action_discard'}}</button>
          <button type="button" class="btn btn-primary" id="btn-send-image">{{_ "app_action_upload"}}</button>
        </div>
      </div>
    </div>
  </div>
</template>

<template name="Admin">
  {{#contentFor "menu"}}
    {{> AdminMenu}}
  {{/contentFor}}

  {{#Layout template="InboxLayout" hasRight=hasRight hasSidebar=hasSidebar}}
    {{> ThreadList}}

    {{> contentFor region="header" template="ThreadHeader" data=thread}}
    {{> contentFor region="right" template="Thread" data=thread}}
    {{#if hasSidebar}}
      {{> contentFor region="sidebar" template="ThreadDetail" data=thread}}
    {{/if}}
  {{/Layout}}
</template>

<template name="AdminMenu">
  <p class="navbar-text pull-left menu-title">{{_ 'app_system'}}</p>
</template>

<template name="AdminMenuItem">
  {{#if currentUser.isAdmin}}
  <li class="{{#if inRouter 'admin'}}active{{/if}}">
    <a href="/admin">
      <i class="fa fa-cubes"></i> <span>{{_ 'app_system'}}</span>
    </a>
  </li>
  {{/if}}
</template>